Learn R Programming

odfWeave (version 0.4.1)

XML Processing Functions: XML Processing Functions

Description

These function takes a character vector of XML for the open Document Format and process it it various ways.

odfTranslate converts some XML modified characters (such as >) to R code (>). odfTranslate also tries to mistake proof the code by anticipating characters that might be in UTF-8 encoding to R compliant characters (e.g. in some fonts, " will become a UTF-8 character, which R will choke on).

stripXmlTag removes any text between "<" and="" "="">" and optionally remove leading or trailing whitespace.

processInLine uses odfTranslate and stripXmlTag to process in-line Sweave statements. Similarly, xml2R does the same thing for code chunks.

Usage

odfTranslate(x, toR = TRUE)
stripXmlTag(x, leadWhite = FALSE, endWhite = FALSE)
processInLine(x)
xml2R(x)

Arguments

x
a character vector
toR
a logical. If TRUE, the text is translated from XML to R. The opposite is done if FALSE.
leadWhite
a logical for removing leading white space
endWhite
a logical for removing tailing white space

Value

  • a character vector

Examples

Run this code
x <- "<text:p text:style-name="P3"><text:s text:c="3"/>lm(y~x)</text:p>"
y <- "\Sexpr{paste(letters[1:5], <text:s text:c="2"/>collapse = ",")}"
z <- "<text:span text:style-name="T1">\Sexpr{x > 2}</text:span>"

stripXmlTag(x)
odfTranslate(y)
xml2R(y)
processInLine(z)

Run the code above in your browser using DataLab